package demo2;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-09-16
 * Time: 23:22
 */
public class Test4 {
    public static Object locker1 = new Object();
    public static Object locker2 = new Object();
    public static int n = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            synchronized (locker1){
                try {
                    locker2.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        Thread t2 = new Thread(() -> {
            while (n < 100){
                n++;
            }
        });
        t1.start();
        t2.start();
        t2.join();
        t1.interrupt();
    }

}
